package HomeWork.msg.entry;


import HomeWork.msg.service.MsgFactory;
import HomeWork.msg.service.SendMsg;

import java.util.Scanner;

public class Entry {

    public static void main(String[] args) {
        // 请输入手机号码
        Scanner sc = new Scanner(System.in) ;
        String phone;
        while (true) {
            System.out.print("请您输入登录的手机号码: ");
            phone = sc.nextLine();
            if (checkPhone(phone)){
                break;
            } else {
                System.out.println("手机号输入错误");
            }
        }
        // 调用发送短信类的方法发送短信验证码
        SendMsg sendMsg = MsgFactory.getSendMsg(0);
        assert sendMsg != null;
        sendMsg.sendMsg(phone);

    }

    public static boolean checkPhone(String phone){
        return phone.matches("^1\\d{10}");
    }

}
